package com.xy.controller;

import com.xy.entity.TestDemo;
import com.xy.repository.TestDemoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * Created by Thinkpad on 2018/1/4.
 */

@ApiIgnore
@RestController
public class TestDemoController {
    @Autowired
    private TestDemoRepository testDemoRepository;
    @GetMapping(value = "/test")
    public String getTest(){
        TestDemo test = new TestDemo();
        test.setName("测试1");
        testDemoRepository.save(test);
        return test.getId() +"name:"+test.getName();
    }

    @GetMapping(value = "/getTest")
    public List<TestDemo> getTestList(){
        return testDemoRepository.findAll();
    }

    @GetMapping(value = "/getTestStr")
    public String getTestStr(){
        String name = testDemoRepository.findById("8a8a8a8160c42e020160c42f656a0002").getName();
        return name;
    }

    /////435435434


}
